package com.geekstudy.week5.config;

import com.geekstudy.week5.kimmking.bean.Klass;
import com.geekstudy.week5.kimmking.bean.Student;
import com.geekstudy.week5.kimmking.service.School;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class Week5Exercise8Config {

    @Autowired
    ApplicationContext applicationContext;

    @Autowired
    List<Student> studentList;

    @Bean(name = "student100")
    public Student student() {
        Student student100 = new Student(100, "学生100", "student100", applicationContext);

        return student100;
    }

    @Bean(name = "student099")
    public Student student099() {
        Student student100 = new Student(99, "学生099", "student099", applicationContext);

        return student100;
    }

    @Bean(name = "klass")
    public Klass klass() {
        Klass klass = new Klass();
        klass.setStudents(studentList);
        return klass;
    }

    @Bean(name = "school")
    public School school() {
        School school = new School();
        return school;
    }


}
